<?php
include_once 'config/common.php';
include_once 'wxpay/lib/WxPay.Data.php';

$wxpayc = newInstance('wxpay');

$post = file_get_contents('php://input');

$data = array();
$WxPayDataBasec = new WxPayDataBase($data);

// $open = fopen('back.log',"w");	
// fwrite($open,'wxpay'.date("Y-m-d H:i:s")."\r\n".$post."\r\n\r\n");
// fclose($open);

if($post!='') {
	$data = $WxPayDataBasec->FromXml($post);
}

if($data['result_code']=='SUCCESS'){
	$wxpayc->success($data['transaction_id'], $data['attach']);
	$open = fopen('back.log',"w");	
	$str = var_export($data,true);
	fwrite($open,'wxpay'.date("Y-m-d H:i:s")."\r\n".$str."\r\n\r\n");
	fclose($open);
	// $success = '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
	// echo "$success";
}
echo 'success';

?>